package mq.cinrad.kafka.app.config;

import java.io.File;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;



@Component
@ConfigurationProperties(prefix = "mq.cinrad.kafka.app.config")
public class ConfigProducerApplication {

	private String kafkaWatchFileConfig;


	

	public String getKafkaWatchFileConfig() {
		return kafkaWatchFileConfig;
	}

	public void setKafkaWatchFileConfig(String kafkaWatchFileConfig) {
		this.kafkaWatchFileConfig = kafkaWatchFileConfig;
	}


	

	@Bean(name = "watchConfig")
	public KafkaWatchFileConfig genKafkaWatchFileConfig() {
		KafkaWatchFileConfig wc = null;

		if (kafkaWatchFileConfig != null) {
			File file = new File(kafkaWatchFileConfig);
			Config conf = ConfigFactory.parseFile(file);
			wc= ProducerConfigUtil.createKafkaWatchFileConfig(conf);
		}

		return wc;
	}

}
